home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / parser / yyerror.y < prev   
Encoding:
Text File  |  1992-09-18  |  2.8 KB  |  156 lines

  1. # include <errors.h>
  2. /*
  3. **   YYERROR -- the routine which error routine yacc calls
  4. **
  5. **    Version:
  6. **        @(#)yyerror.y    8.2    2/6/85
  7. */
  8.  
  9. yyerror(errmessage)
  10. char    *errmessage;
  11. {
  12. #    ifdef    xPTR1
  13.     tTfp(60, 6, "yyerror: an error from yacc itself\n");
  14. #    endif
  15.  
  16.     if (sequal(errmessage, "syntax error"))
  17.         par_error(SYMERR, WARN, 0);
  18.     else
  19.         par_error(YOVRFLOW, WARN, 0);
  20. }
  21.  
  22. /*
  23. **   PAR_ERROR -- the error routine for the parser
  24. **
  25. **    Par_error sends its arguments to print_error(), the front-end
  26. **    error processor.  If result = FATAL then reset() is called,
  27. **    otherwise, the error is assumed to be recoverable, and parsing
  28. **    continues.
  29. **
  30. **    Parameters:
  31. **        num -- the number of the error (2000 - 2999).
  32. **        result -- if = FATAL then reset, otherwise return.
  33. **        a, b, c -- arbitrary arguments to the error routine.
  34. **        
  35. **    Returns:
  36. **        if result is not FATAL
  37. **
  38. **    Requires:
  39. **        print_error() -- of the monitor
  40. **        
  41. **    Called By:
  42. **        parser routines
  43. **        scanner routines
  44. **
  45. **    Written:
  46. **        1979 (jiw)
  47. **        13 feb 1980 modified for monpar (jiw)
  48. */
  49.  
  50. par_error(num, result, a, b, c)
  51. int    num;
  52. int    result;
  53. char    *a, *b, *c;
  54. {
  55.     char        buff[30];
  56.     register char    *buf;
  57.  
  58.     extern int    Err_current;
  59.     extern int    Err_fnd;
  60.     extern int    Opflag;
  61.     extern int    yyline;
  62.  
  63.     resetp();
  64.  
  65.     buf = buff;
  66.  
  67. #    ifdef    xPTR1
  68.     tTfp(60, 7, "par_error: %d, (fatal = %d), a, b, c.\n", num, result, a, b, c);
  69. #    endif
  70.  
  71.     yyerrflag = 3;        /* tell yyparse that an error has been found */
  72.  
  73.     /* 
  74.     **    if Err_current is true at this point,
  75.     **    it is the second error found in the statement.
  76.     **    Thus for the simple error recovery currently
  77.     **    used no other message should be printed.
  78.     */
  79.  
  80.     if (Err_current)
  81.     {
  82.         if (result != FATAL)
  83.             return;
  84.         else
  85.         {
  86. #            ifdef    xPTR1
  87.             tTfp(60, 9, "par_error: a non recoverable error\n");
  88. #            endif
  89.  
  90.             endgo();
  91.  
  92.             error(0);
  93.         }
  94.     }
  95.  
  96. #    ifdef    xPTR1
  97.     tTfp(60, 8, "par_error: first error.\n");
  98. #    endif
  99.  
  100.     Err_fnd += 1;        /* check syntax of remainder */
  101.     Err_current = 1;    /* error was found in this statement */
  102.  
  103.     if (num == SYMERR || num == NXTCMDERR)
  104.     {
  105.         /* syntax error */
  106.         a = buf;
  107.         b = 0;
  108.         switch (Lastok.toktyp)
  109.         {
  110.           case I2CONST:
  111.             itoa(*(short *)Lastok.tok, buf);
  112.             break;
  113.  
  114.           case I4CONST:
  115.             smove(locv(*(long *)Lastok.tok), buf);
  116.             break;
  117.  
  118.           case F4CONST:
  119.             ftoa(*(float *)Lastok.tok, buf, 10, 3, 'n');
  120.             break;
  121.  
  122.           case F8CONST:
  123.             ftoa(*(double *)Lastok.tok, buf, 10, 3, 'n');
  124.             break;
  125.  
  126.           case SCONST:
  127.             smove(Lastok.tok, buf);
  128.             break;
  129.  
  130.           case 0:
  131.             a = "EOF";
  132.             break;
  133.  
  134.           default:
  135.             syserr("bad Lastok format");
  136.         }
  137.         num += Opflag;    /* choosing correct error */
  138.     }
  139.  
  140.     if (result != FATAL)
  141.         error(num, iocv(yyline), a, b, c, 0);
  142.     else
  143.     {
  144. #        ifdef    xPTR1
  145.         tTfp(60, 9, "par_error: a non recoverable error\n");
  146. #        endif
  147.  
  148.         error(num, iocv(yyline), a, b, c, 0);
  149.     }
  150. }
  151. neederr(errnum)
  152. int    errnum;
  153. {
  154.     par_error(errnum, WARN, 0);
  155. }
  156.